<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>网站设置</title>
    <link rel="stylesheet" href="../templates/style/plugins/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../templates/style/build/css/doc.css" media="all">
    <script src="../templates/style/plugins/layui/layui.js"></script>
    <script src="../templates/style/plugins/layui/jquery-3.3.1.min.js"></script>
    <script src="js/getGroup.js"></script>
    <!-- 这个是用于测试session是不是存在 -->
    <script>
        layui.use(['jquery', 'layer'], function () {
            var returnmsg = getGroup(2);
            layer.alert(returnmsg, {offset: 't',icon: 6});
        });
    </script>

</head>

<body>
    <div class="kit-doc">
        <!--这里写页面的代码-->
        <blockquote class="layui-elem-quote">注意这里是项目的左侧菜单栏目管理，如果是系统自带的，我们禁止你删除，如果是你自己添加的，你可以选择可以删除还是不可以删除</blockquote>
        <div class="kit-doc-title">
            <fieldset>
                <legend><a name="blockquote">菜单管理</a></legend>
            </fieldset>
        </div>
        <div>
            <button class="layui-btn">添加</button>
            <div class="layui-inline" style="float: right">
                <div class="layui-input-inline">
                    <input name="phone" lay-verify="required|phone" autocomplete="off" class="layui-input" type="tel">
                </div>
                <button class="layui-btn layui-btn-primary">搜索</button>
            </div>
        </div>


        <table class="layui-table" lay-data="{width: 892, height:332, url:'/demo/table/user/', page:true, id:'idTest'}" lay-filter="demo">
            <thead>
            <tr>
                <th lay-data="{type:'checkbox', fixed: 'left'}"></th>
                <th lay-data="{field:'id', width:80, sort: true, fixed: true}">ID</th>
                <th lay-data="{field:'username', width:80}">用户名</th>
                <th lay-data="{field:'sex', width:80, sort: true}">性别</th>
                <th lay-data="{field:'city', width:80}">城市</th>
                <th lay-data="{field:'sign', width:160}">签名</th>
                <th lay-data="{field:'experience', width:80, sort: true}">积分</th>

                <th lay-data="{field:'classify', width:80}">职业</th>
                <th lay-data="{field:'wealth', width:135, sort: true}">财富</th>
                <th lay-data="{field:'score', width:80, sort: true, fixed: 'right'}">评分</th>
                <th lay-data="{fixed: 'right', width:178, align:'center', toolbar: '#barDemo'}"></th>
            </tr>
            </thead>
        </table>

        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
        </script>

        <!--这里写页面的代码-->
    </div>

    <script>
    layui.use('table', function(){
        var table = layui.table;
        //监听表格复选框选择
        table.on('checkbox(demo)', function(obj){
            console.log(obj)
        });
        //监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                layer.msg('ID：'+ data.id + ' 的查看操作');
            } else if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    obj.del();
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                layer.alert('编辑行：<br>'+ JSON.stringify(data))
            }
        });

        var $ = layui.$, active = {
            getCheckData: function(){ //获取选中数据
                var checkStatus = table.checkStatus('idTest')
                    ,data = checkStatus.data;
                layer.alert(JSON.stringify(data));
            }
            ,getCheckLength: function(){ //获取选中数目
                var checkStatus = table.checkStatus('idTest')
                    ,data = checkStatus.data;
                layer.msg('选中了：'+ data.length + ' 个');
            }
            ,isAll: function(){ //验证是否全选
                var checkStatus = table.checkStatus('idTest');
                layer.msg(checkStatus.isAll ? '全选': '未全选')
            }
        };

        $('.demoTable .layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
    </script>

</body>

</html>